package year2019.month08;

/**
 * 链表结构简单实现
 * @param <K>
 * @param <V>
 */
public class Node<K, V>{
    K key;
    V value;
    Node<K, V> next;
    Node(){}
    Node(K key, V value){
        this.key=key;
        this.value=value;
    }

    public V setValue(V value){
        this.value = value;
        return value;
    }

    public V getValue(){
        return value;
    }

    public static void main(String[] args){
        Node<String, Integer> root = new Node<>("root",1);
        root.next = new Node<>("next",2);
        root.next.next = new Node<>("next",3);
        root.next.next.next = new Node<>("next",300);

        Node<String, Integer> node = root;
        while (node!=null){
            System.out.println(node.getValue());
            node=node.next;
        }
    }
}
